Research
Security News
Malicious npm Package Typosquats react-login-page to Deploy Keylogger
Socket researchers unpack a typosquatting package with malicious code that logs keystrokes and exfiltrates sensitive data to a remote server.
egg-logger
Advanced tools
Readme
Egg logger.
Including two base class, Logger
and Transport
:
$ npm i egg-logger
Create a Logger
and add a file Transport
.
const Logger = require('egg-logger').Logger;
const FileTransport = require('egg-logger').FileTransport;
const ConsoleTransport = require('egg-logger').ConsoleTransport;
const logger = new Logger();
logger.set('file', new FileTransport({
file: '/path/to/file',
level: 'INFO',
}));
logger.set('console', new ConsoleTransport({
level: 'DEBUG',
}));
logger.debug('debug foo'); // only output to stdout
logger.info('info foo');
logger.warn('warn foo');
logger.error(new Error('error foo'));
logger.disable('file');
logger.info('info'); // output nothing
logger.enable('file');
logger.info('info'); // output 'info' string
Duplicate error log to other logger.
Accept an options.excludes
to special whether excludes some tranports.
logger.duplicate('error', errorLogger, { excludes: [ 'console' ]});
logger.error(new Error('print to errorLogger')); // will additional call `errorLogger.error`
Redirect special level log to other logger.
oneLogger.redirect('debug', debugLogger); // all debug level logs of `oneLogger` will delegate to debugLogger
logger.reload(); // will close the exists write stream and create a new one.
You can make your own Transport
for logging,e.g.: send log to your logging server.
const urllib = require('urllib');
const Transport = require('egg-logger').Transport;
class UrllibTransport extends Transport {
log(level, args, meta) {
const msg = super.log(level, args, meta);
return urllib.request('url?msg=' + msg);
}
}
const logger = new Logger();
logger.set('remote', new UrllibTransport({
level: 'DEBUG',
}));
logger.info('info');
set environment NODE_CONSOLE_LOGGRE_LEVEL = 'INFO' | 'WARN' | 'ERROR'
fengmk2 | dead-horse | popomore | atian25 | semantic-release-bot | mansonchor |
---|---|---|---|---|---|
whxaxes | Jeff-Tian | waitingsong | sjfkai | congyuandong | lix059 |
killagu | duqingyu | AmazingCaddy | linrf | XadillaX | luckydrq |
This project follows the git-contributor spec, auto updated at Wed May 08 2024 09:39:22 GMT+0800
.
FAQs
Unknown package
The npm package egg-logger receives a total of 31,487 weekly downloads. As such, egg-logger popularity was classified as popular.
We found that egg-logger demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 14 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers unpack a typosquatting package with malicious code that logs keystrokes and exfiltrates sensitive data to a remote server.
Security News
The JavaScript community has launched the e18e initiative to improve ecosystem performance by cleaning up dependency trees, speeding up critical parts of the ecosystem, and documenting lighter alternatives to established tools.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.